import PlayerDataMgr from "../PlayerDataMgr";
import ResManager from "../ResManager";

export default class LevelLogic {

    static load() {

    }

    /**
     * 老用户，则依次取出未完成的关卡，都完成了，则开放关卡选择界面；
     * 新用户，则从第一关开始，都完成了，则开放关卡选择界面
     * 
     */
    static getCurrentPlayLevel() {
        let levelCount = ResManager.getLevelResArray().length;
        for(let i = 0; i < levelCount; ++i) {
            if(PlayerDataMgr.getInstance().getLevelStar(i) == 0) {
                return i;
            }
        }
        return PlayerDataMgr.getInstance().getLastLevelIndex();
    }

    static isAllLevelDone() {
        for (let i = 0; i < ResManager.levelResArray.length; ++i) {
            let star = PlayerDataMgr.getInstance().getLevelStar(i)
            if(star == 0)
                return false
        }
        return true;
    }
}
